package com.xfcy.blog.dto;


import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xfcy.blog.common.constant.DateConstant;
import com.xfcy.blog.valid.AddGroup;
import com.xfcy.blog.valid.ListValue;
import com.xfcy.blog.valid.UpdateGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;


/**
 * 接收前台传过来的
 * @author 晓风残月Lx
 * @date 2023/4/18 20:09
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FriendLinkDTO implements Serializable {
    // 主键id
    @NotNull(message = "修改必须指定id", groups = UpdateGroup.class)
    @Null(message = "新增不能指定id", groups = {AddGroup.class})
    private Integer id;
    //网站名称
    @NotBlank(message = "网站名称必须提交", groups = {AddGroup.class, UpdateGroup.class})
    private String name;
    //网站地址
    @NotBlank(message = "网站地址不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @URL(message = "网站地址必须是一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
    private String url;
    //网站头像地址
    @NotBlank(message = "网站头像地址不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @URL(message = "网站头像地址必须是一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
    private String avatar;
    //网站描述
    @NotBlank(message = "网站描述不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String info;
    //邮箱
    @Email(message = "邮箱必须是一个合法的邮箱地址",  groups = {AddGroup.class, UpdateGroup.class})
    private String email;

    //排序
    @Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 9, message = "排序必须小于等于0", groups = {AddGroup.class, UpdateGroup.class})
    private Integer sort;

    //ENUM-状态:"0-下架","1-审核" 2-通过
    @ListValue(vals = {0,1,2}, groups = {UpdateGroup.class,AddGroup.class})
    private Integer status;

    private String reason;

    //创建时间
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = DateConstant.FORMAT_STRING, timezone = DateConstant.GMT_TIMEZONE)
    private LocalDateTime createTime;
    //修改时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = DateConstant.FORMAT_STRING, timezone = DateConstant.GMT_TIMEZONE)
    private LocalDateTime updateTime;


}
